package com.fer.tankr.scenes;

import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.background.RepeatingSpriteBackground;
import org.andengine.entity.scene.menu.MenuScene;
import org.andengine.entity.scene.menu.item.IMenuItem;
import org.andengine.entity.scene.menu.item.SpriteMenuItem;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.fer.tankr.AssetManagerImpl;

public class MainMenuScene extends MenuScene {

	public final static int ITEM_TITLE = 0;
	public final static int ITEM_PLAY = 1;
	public final static int ITEM_HIGH_SCORES = 2;
	public final static int ITEM_REQUEST_FEATURE = 3;
	public final static int ITEM_HELP = 4;
	
	private IMenuItem itemTitle;
	private IMenuItem itemPlay;
	private IMenuItem itemHighScores;
	private IMenuItem itemRequest;
	private IMenuItem itemHelp;
	
	public BitmapTextureAtlas mBitmapTextureAtlas;
	public RepeatingSpriteBackground mGrassBackground;
	public ITextureRegion grassTexture;
	
	public MainMenuScene(Camera camera, VertexBufferObjectManager pVertexBufferObject, AssetManagerImpl assetManager) {
		super(camera);
		
		setBackground(assetManager.mGrassBackground);
		
		itemTitle = new SpriteMenuItem(ITEM_TITLE, assetManager.menuTitle, pVertexBufferObject);
		itemPlay = new SpriteMenuItem(ITEM_PLAY, assetManager.menuPlay,pVertexBufferObject );
		itemHighScores = new SpriteMenuItem(ITEM_HIGH_SCORES, assetManager.menuHiScores, pVertexBufferObject);
		itemRequest = new SpriteMenuItem(ITEM_REQUEST_FEATURE, assetManager.menuRequest, pVertexBufferObject);
		itemHelp = new SpriteMenuItem(ITEM_HELP, assetManager.menuHelp, pVertexBufferObject);
		
		float width = camera.getWidth()/4;
		float height = camera.getHeight()/6;
		float blockWidth = itemPlay.getWidth()/2;
		float blockHeight = itemPlay.getHeight()/2;
		
		float x0 = 2*width-blockWidth;
		float x1 = width-blockWidth;
		float x2 = 3*width-blockWidth;
		float y0 = height-blockHeight;
		float y1 = 3*height-blockHeight;
		float y2 = 5*height-blockHeight;
		
		itemTitle.setPosition(x0, y0);
		itemPlay.setPosition(x1,y1);
		itemHighScores.setPosition(x2,y1);
		itemRequest.setPosition(x1,y2);
		itemHelp.setPosition(x2,y2);
		
		addMenuItem(itemTitle);
		addMenuItem(itemPlay);
		addMenuItem(itemHighScores);
		addMenuItem(itemRequest);
		addMenuItem(itemHelp);
	}
}
